/**
 * Created by HFY on 2017/3/17.
 */
function getUrlRelativePath() {
    var url = document.location.toString();
    var arrUrl = url.split("//");
    var relUrl = arrUrl[1].split("/")[1]
    return relUrl;
}
function do_switch() {
    if($("#switch_commonCloud")[0]!=undefined)
    {
        $.post("/" + getUrlRelativePath() + "/" + "do_switch", {
            'switch_commonCloud': $("#switch_commonCloud").val()
        })
    }
    else if($("#switch_syncCloud")[0]!=undefined)
    {
        $.post("/" + getUrlRelativePath() + "/" + "do_switch", {
            'switch_syncCloud': $("#switch_syncCloud").val()
        })
    }
}
$(".folder_strike_li03").click(function () {
    $(".new_release").show();
});
//显示缩略图或列表
$(function zopenCloud_switch(){
    if($("#switch_commonCloud")[0]!=undefined) {
        if($("#switch_commonCloud").val()=='true') {
            $(".firm_name").hide();
            $(".folder").hide();
            $(".center_folder").show();
            $(".folder-center").show();
            $(".center_top_right_a1").hide();
            $(".center_top_right_a2").show();
        } else if($("#switch_commonCloud").val()=='false' || $("#switch_commonCloud").val() == null) {
            $(".firm_name").show();
            $(".folder").show();
            $(".center_folder").hide();
            $(".folder-center").hide();
            $(".center_top_right_a1").show();
            $(".center_top_right_a2").hide();
        }
    } else if($("#switch_syncCloud")[0]!=undefined) {
        if($("#switch_syncCloud").val()=='true') {
            $(".firm_name").hide();
            $(".folder").hide();
            $(".center_folder").show();
            $(".folder-center").show();
            $(".center_top_right_a1").hide();
            $(".center_top_right_a2").show();
           
        } else if($("#switch_syncCloud").val()=='false' || $("#switch_commonCloud").val() == null) {
            $(".firm_name").show();
            $(".folder").show();
            $(".center_folder").hide();
            $(".folder-center").hide();
            $(".center_top_right_a1").show();
            $(".center_top_right_a2").hide();
        }
    }
});
//顶部tab栏切换
var navHeadLi = $(".nav_head_ul li");
var firmNameHeight = $(window).height() - $(".firm_name").offset().top;
for (var i = 0; i < navHeadLi.length; i++) {
    navHeadLi[i].indexs = i;
    navHeadLi[i].onclick = function () {
        for (var j = 0; j < navHeadLi.length; j++) {
            navHeadLi[j].className = "";
        }
        this.className = "navbar_nav_bgc";
        if (this.indexs == 0) {
            $(".enterprise").show();
            $(".operation_history").hide();
        } else if (this.indexs == 2) {
            $(".operation_history").fadeIn("slow");
            $(".enterprise").hide();
        } else if (this.indexs == 1) {
            $(".operation_history").hide();
            $(".enterprise").hide();
        }
    }
}
var firmNameHeight = $(window).height() - $(".firm_name").offset().top;
//动态给文件夹设置高度
$(".firm_name").css({
    "height": firmNameHeight - 260
});
$(".center_folder").css({
    "height": firmNameHeight - 60
});
//重命名显示隐藏
var folderStrike = $(".folder_strike");
var folderA = $(".folder_a_02");
//列表显示隐藏
var folderStrike2 = $(".folder_strike_02");
var firmNameUl = $(".firm_name_ul");
var sun = 1;
var firmNameSelect = $(".firm_name_select");
var folderStrike02null = $(".folder_strike_02");
var folderUlLiA = $(".folder_ul li a");
var firmNameInputHide = $(".firm_name_input");
var firmNameAa = $(".firm_name_a")
folderUlLiA.click(function () {
    folderStrike2.hide();
    firmNameAa.show();
});
for (i = 0; i < firmNameUl.length; i++) {
    firmNameUl[i].onmouseenter = function () {
        this.className = "firm_name_ul firm_name_ul_add";
        //新版本显示
        $(".folder_strike_li03").click(function () {
            $(".new_release").show();
        });
        $(".folder_ul_li03").click(function () {
            $(".new_release").show();
        });
        //鼠标移入添加：firm_name_ul_add
        var folderStrike02 = $(".firm_name_ul_add .folder_strike_02");
        firmNameSelect.unbind("click").click(function () {
            var firmNameHeight = $(window).height() - $(".firm_name").offset().top;
            //动态给文件夹设置高度
            $(".firm_name").css({
                "height": firmNameHeight - 100
            });
            $(".center_folder").css({
                "height": firmNameHeight - 60
            });
            folderStrike02null.slideUp();//没有添加class的重命名
            firmNameInputHide.hide();//input
            firmNameAa.show();//文件夹名字
            if (sun == 1) {
                folderStrike02.slideDown();
                sun = 0;
            } else if(sun == 0){ 
                sun = 1;
                folderStrike02.slideUp();
            }
            return false;
        });
        var folderUlLiA01 = $(".firm_name_ul_add .folder_ul a").slice(0, 1);
        //重命名
        folderUlLiA01.click(function () {
            sun = 1;
            var firmNameInput = $(".firm_name_ul_add .firm_name_input");
            var firmNameTextInput = $(".firm_name_ul_add .firm_name_text input");
            firmNameInputHide.hide();
            firmNameInput.show();
            firmNameTextInput.select();
            //重命名-input
            //没有center_folder_ul_li隐藏
            var firmNameLiA = $(".firm_name_ul_add .firm_name_a");
            firmNameLiA.hide();
            var firmInputA1 = $(".firm_name_ul_add .firm_name_input_a1");
            var firmInputAbolishA = $(".firm_name_ul_add .firm_name_input_abolish a");
            //去掉后缀
            var firmInputvalue = firmNameLiA.text().substring(0,firmNameLiA.text().lastIndexOf("."));
            //文件夹赋值
            if(firmInputvalue == "") {
                firmInputvalue = firmNameLiA.text();
            }  
            if($(".firm_name_ul_add .folder_diff_list img").attr("src") == "/static/images/ic_folder.png") {
                firmInputvalue = firmNameLiA.text();
            }
             //没有去掉后缀
            var firmInputvalueS = firmNameLiA.text();
            //split返回的是数组
            firmNameTextInput.val(firmInputvalue);
            firmNameInput.css({
                "display": "block"
            });
            var t = firmNameTextInput.val();
            firmNameTextInput.val("").focus().val(t);
            firmInputA1.click(function () {
                firmNameLiA.show();
                //input的值为空
                if (firmNameTextInput.val() == '') {
                    firmNameLiA.html(firmInputvalueS);
                } else {
                    firmNameLiA.text("");
                    firmNameLiA.html(firmNameTextInput.val());
                }
                firmNameInput.css({
                    "display": "none"
                });

                return false;
            });
            firmInputAbolishA.click(function () {
                firmNameInput.hide();
                firmNameLiA.show();
            });
            return false;
        });
    };
    firmNameUl[i].onmouseleave = function () {
        for (j = 0; j < firmNameUl.length; j++) {
            firmNameUl[j].className = "firm_name_ul"
        }
    }
    //鼠标移入显示详细信息
    var firmNameSpan = $(".firm_name_span");
    firmNameSpan[i].onmouseenter = function () {
        $(".firm_name_ul_add .firm_name_text").show();
        firmNameSpan.attr("title",$(this).text());
    }
     //鼠标移入显示详细信息
    var firmNameSpan = $(".firm_name_a")
    firmNameSpan[i].onmouseenter = function () {
        firmNameSpan.attr("title",$(this).text());
    }
}
//切换文件夹显示方式
var center_folder = $(".center_folder");
var firm_name = $(".firm_name");
var center_top_right = $(".center_top_right");
center_top_right.click(function () {
    do_switch();
    $(".folder_strike_02").hide();
    $(".firm_name_input").hide();
    $(".center_input").hide();
    $(".firm_name_a").show();
    $(".center_folder_ul_span").show();
    $(".folder_a_02").hide();
    if (center_folder.css("display") == "block") {
        center_folder.css({
            "display": "none"
        });
        $(".folder-center").hide();
        $(".folder").fadeIn("slow");
        $(".center_top_right_a1").fadeIn("slow");
        $(".center_top_right_a2").fadeOut("hide");
        firm_name.fadeIn("slow");
        //回顶部
        if ($(".firm_name_row").height() > firmNameHeight) {
            $(".bounce_top").fadeIn("slow");
        } else {
            $(".bounce_top").hide();
        }
    } else if (firm_name.css("display") == "block") {
        firm_name.css({
            "display": "none"
        });
        center_folder.show();
        $(".center_top_right_a1").fadeOut("hide");
        $(".center_top_right_a2").fadeIn("slow");
        $(".folder").hide();
        $(".folder-center").fadeIn("slow");
        //回顶部
        if ($(".center_folder").height() < $(".center_folder_ul").height()) {
            $(".bounce_top").fadeIn("slow");
        } else {
            $(".bounce_top").hide();
        }
    }
});
//点击改变缩略图背景色
var centerFolderUlLi = $(".center_folder_ul > li");
var arr = $('.firm_name_checkbox');
for (var i = 0; i < centerFolderUlLi.length; i++) {
    centerFolderUlLi[i].index = i;
    centerFolderUlLi[i].onclick = function (event) {
        $(".folder_checkbox").prop("checked",false);
        $(".center_folder_ul_span").show();
        // $(".seek_download_span").text("下载");
        e = window.event || event
        if(e.ctrlKey) {
            //ctrl键单项选择
            // $(".seek_download_span").text("批量下载");
            $(".seek_ul").fadeIn("show");
            $(".folder_a_02").hide();
            if (this.className != "center_folder_ul_li") {
                this.className = "center_folder_ul_li"
                arr.eq(this.index).prop("checked",true);
            } else if (this.className == "center_folder_ul_li") {
                this.className = ""
                arr.eq(this.index).prop("checked",false);
            }
            for(var i = 0; i < centerFolderUlLi.length; i++) {
                if (centerFolderUlLi[i].className != "center_folder_ul_li") {
                    $(".folder_center_checkbox").prop("checked",false);
                    $(".folder_checkbox").prop("checked",false);
                    return false;
                }else {
                    $(".folder_center_checkbox").prop("checked",true);
                    $(".folder_checkbox").prop("checked",true);
                }
            }
            return false;
        }
        $(".folder_center_checkbox").prop("checked", false);
        $(".seek_ul").fadeIn("slow");
        for (var j = 0; j < centerFolderUlLi.length; j++) {
            centerFolderUlLi[j].className = ""
            arr.prop("checked",false);
            folderStrike.css({
                "display": "none"
            });
        }
        this.className = "center_folder_ul_li";
        arr.eq(this.index).prop("checked",true);
        folderA.css({
            "display": "none"
        });
        //让有这个center_folder_ul_li属性的LI标签显示a标签
        var centerUlLiA = $(".center_folder_ul_li .folder_a_02");
        if (centerUlLiA) {
            centerUlLiA.slideDown();
        }
        //重命名显示隐藏
        var centerUlLiStrike = $(".center_folder_ul_li .folder_strike");
        var index1 = 1;
        centerUlLiA.click(function () {
            if (index1 == 1) {
                index1 = 0;
                centerUlLiStrike.css({
                    "display": "block"
                });
            } else if (index1 == 0) {
                index1 = 1;
                centerUlLiStrike.css({
                    "display": "none"
                });
            }
            return false;
        });
        var centerInputHide = $(".center_input");
        var folderStrikeLiA = $(".center_folder_ul_li .folder_strike_ul a").slice(0, 1);
        folderStrikeLiA.click(function () {
            //先让所有的标题显示
            $(".center_folder_ul_span").show();
            folderStrike.hide();
            //重命名-input
            //没有center_folder_ul_li隐藏
            centerInputHide.css({
                "display": "none"
            });
            var centerFolderUlSpan = $(".center_folder_ul_li .center_folder_ul_span");
            var centerInput = $(".center_folder_ul_li .center_input");
            var centerInputText = $(".center_folder_ul_li .center_text input");
            var centerInputA1 = $(".center_folder_ul_li .center_input_a1");
            var centerInputAbolishA = $(".center_folder_ul_li .center_input_abolish a");
            //去掉后缀
            //获取路劲判断是否文件夹
            var centerInputvalue = centerFolderUlSpan.text().substring(0,centerFolderUlSpan.text().lastIndexOf("."));
            //文件夹赋值
            if(centerInputvalue == "") {
                centerInputvalue = centerFolderUlSpan.text()
            }  
             if($(".center_folder_ul_li .folder_diff_omit img").attr("src") == "/static/images/ic_folder01.png") {
                centerInputvalue = centerFolderUlSpan.text();
            }
            //没有去掉后缀
            var centerInputvalueS = centerFolderUlSpan.text();
            //split返回的是数组
            centerInputText.val(centerInputvalue);
            centerInput.show();
            centerFolderUlSpan.hide();
            //光标自动放在input尾部
            var t = centerInputText.val();
            centerInputText.val("").focus().val(t);
            //选择文本
            centerInputText.focus(function(){
                this.select();
            });
            //input确定修改
            centerInputA1.click(function () {
                //span的值为空
                if (centerInputText.val() == '') {
                    centerFolderUlSpan.show();
                    //没有去掉后缀
                    centerFolderUlSpan.html(centerInputvalueS);
                } else {
                    centerFolderUlSpan.show();
                    centerFolderUlSpan.text("");
                    centerFolderUlSpan.html(centerInputText.val());
                }
                centerInput.css({
                    "display": "none"
                });
                return false;
            });
            //input取消修改
            centerInputAbolishA.click(function () {
                centerInput.hide();
                centerFolderUlSpan.show();
            });
            return false;
        });
    }
}   
//全选和反选
var seekUl = $(".seek_ul");
$(".folder_checkbox").click(function () {
    if (this.checked) {
        $(".firm_name_01 :checkbox").prop("checked", true);
        seekUl.fadeIn("slow");
    } else {
        $(".firm_name_01 :checkbox").prop("checked", false);
        seekUl.fadeOut("hide");
    }
});
//设置全选复选框
$(".firm_name_01 :checkbox").click(function () {
    allchk();
});
function allchk() {
    var chknum = $(".firm_name_01 :checkbox").size();//选项总个数
    var chk = 0;
    $(".firm_name_01 :checkbox").each(function () {
        if ($(this).prop("checked") == true) {
            chk++;
        }
    });
    if (chk > 0) {
        seekUl.fadeIn("slow");
    } else {
        seekUl.fadeOut("hide");
    }
    if (chknum == chk) {//全选
        $(".folder_checkbox").prop("checked", true);
    } else {//不全选
        $(".folder_checkbox").prop("checked", false);
    }
}
//缩略图文件夹全选
$(".folder_center_checkbox").click(function () {
    if (this.checked) {
        $(".folder_checkbox").prop("checked", true);
        arr.prop("checked",true);
        seekUl.fadeIn("slow");
        folderStrike.fadeOut("hide");
        for (var j = 0; j < centerFolderUlLi.length; j++) {
            centerFolderUlLi[j].className = "";
            centerFolderUlLi[j].className = "center_folder_ul_li";
        }
    } else {
        seekUl.fadeOut("hide");
        $(".folder_checkbox").prop("checked", false);
        arr.prop("checked",false);
        for (var j = 0; j < centerFolderUlLi.length; j++) {
            centerFolderUlLi[j].className = "";
        }
    }
    folderA.hide();
});
//兼容ie8input中的placeholder
$(function () {
    $('input[placeholder]').placeholder();
});
$(window).resize(function () {
    var firmNameHeight = $(window).height() - $(".firm_name").offset().top;
    //动态给文件夹设置高度
    $(".firm_name").css({
        "height": firmNameHeight-60
    });
    $(".center_folder").css({
        "height": firmNameHeight - 60
    });
});
//点击删除按钮
$(".seek_ul_li").click(function () {
    $(".confirm_delete").show();
});
$(".confirm_delete_a1").click(function () {
    $(".confirm_delete").hide();
});
//点击移动至
$(".seek_ul_move").click(function () {
    $(".move_to").show();
});
$(".move_to_cancel").click(function () {
    $(".move_to").hide();
});
$(".move_to_top_cancel").click(function () {
    $(".move_to").hide();
});
//点击复制至
$(".seek_ul_copy").click(function () {
    $(".copy_to").show();
});
$(".copy_to_cancel").click(function () {
    $(".copy_to").hide();
});
$(".copy_to_top_cancel").click(function () {
    $(".copy_to").hide();
});
//点击上传至
$(".seek_a1").click(function () {
    $(".uploading_to").show();
$(".dz-default span").text("拖拽文件或点击这里上传！");
});
$(".uploading_to_top_cancel").click(function () {
    $(".uploading_to").hide();
    //刷新页面
    location.reload();
});
//回到顶部
if ($(".firm_name_row").height() > firmNameHeight) {
    $(".bounce_top").fadeIn("slow");
} else {
    $(".bounce_top").hide();
}
$(".bounce_top").click(function () {
    $(".center_folder").animate({
        scrollTop: 0
    }, 500);
    $(".firm_name").animate({
        scrollTop: 0
    }, 500);
});
/**
 * sort
 * 中文排序
 * @param num为1或-1
 */
function sort(num) {
    //排序
    var firmA = $(".firm_name_ul li .firm_name_a");
    var arr = [];
    for (var i = 0; i < firmA.length; i++) {
        arr[i] = firmA[i];
    }
    var len = arr.length;
    var temp;
    while(len > 0) {
        for (var i = 0; i < len-1; i++) {
            if(arr[i].innerHTML.localeCompare(arr[i+1].innerHTML) == num) {
                temp = arr[i];
                arr[i] = arr[i+1];
                arr[i+1] = temp;
            }
        }
        len--;
    }
    $(".firm_name_row").empty()
    $(".firm_name_row").append(arr[0].parentNode.parentNode);
    for(var i = 0; i < arr.length ; i++) {
        $(".firm_name_row").append(arr[i].parentNode.parentNode);
    }
}
/**
 * 名字排序
 * @param num 1或-1
 */
function ksort(num) {
    //排序
    var firmSpan = $(".firm_name_ul .firm_name_02 .firm_name_span");
    var arrSpan = [];
    for (var i = 0; i < firmSpan.length; i++) {
        arrSpan[i] = firmSpan[i];
    }
    var lenSpan = arrSpan.length;
    var tempSpan;
    while(lenSpan > 0) {
        for (var i = 0; i < lenSpan-1; i++) {
            if(arrSpan[i].innerHTML.localeCompare(arrSpan[i+1].innerHTML) == num) {
                tempSpan = arrSpan[i];
                arrSpan[i] = arrSpan[i+1];
                arrSpan[i+1] = tempSpan;
            }
        }
        lenSpan--;
    }
    $(".firm_name_row").empty()
    $(".firm_name_row").append(arrSpan[0].parentNode.parentNode);
    for(var i = 0; i < arrSpan.length ; i++) {
        $(".firm_name_row").append(arrSpan[i].parentNode.parentNode);
    }
}
/**
 * sort2
 * 排序再次添加功能
 */
function sort2() {
    // $(".firm_name_input").hide();
    //全选和反选
    var seekUl = $(".seek_ul");
    $(".folder_checkbox").click(function(){
        if(this.checked){
            $(".firm_name_01 :checkbox").prop("checked", true);
            seekUl.fadeIn("slow");
        }else{
            $(".firm_name_01 :checkbox").prop("checked", false);
            seekUl.fadeOut("hide");
        }
    });
//设置全选复选框
    $(".firm_name_01 :checkbox").click(function(){
        allchk();
    });
//内容文件夹全选
    $(".folder_center_checkbox").click(function () {
    if (this.checked) {
        $(".folder_checkbox").prop("checked", true);
        arr.prop("checked",true);
        seekUl.fadeIn("slow");
        folderStrike.fadeOut("hide");
        for (var j = 0; j < centerFolderUlLi.length; j++) {
            centerFolderUlLi[j].className = "";
            centerFolderUlLi[j].className = "center_folder_ul_li";
        }
    } else {
        seekUl.fadeOut("hide");
        $(".folder_checkbox").prop("checked", false);
        arr.prop("checked",false);
        for (var j = 0; j < centerFolderUlLi.length; j++) {
            centerFolderUlLi[j].className = "";
        }
    }
    folderA.hide();
});
    //点击重命名隐藏
    $(".folder_ul li a").click(function () {
        $(".folder_strike_02").hide();
    });
    //空白处点击
    $(".firm_name_ul").mouseleave(function () {
        _flag = false;
    });
    $(".firm_name_ul").mouseover(function () {
        _flag = true;
    });
}
//排序
var number = 1;
//文件名排序
$(".folder_01 a").click(function() {
    if(number == 1) {
        sort(number);
        number = -1;
    }else if(number == -1) {
        sort(number);
            number = 1;
    }
    sort2();
});
var numberName = 1;
//名字排序
$(".folder_02 a").click(function() {
    if(numberName == 1) {
        ksort(numberName);
        numberName = -1;
    }else if(numberName == -1) {
        ksort(numberName);
        numberName = 1;
    }
    sort2();
});
//移动至-高亮显示
var moveToUlLi = $(".move_to_ul li");
for (var i = 0; i < moveToUlLi.length; i++) {
    moveToUlLi[i].onclick = function () {
        for (var j = 0; j < moveToUlLi.length; j++) {
            moveToUlLi[j].className = "";
        }
        this.className = "move_bac_click ";
    }
}
var copyToUlLi = $(".copy_to_ul li");
for (var i = 0; i < copyToUlLi.length; i++) {
    copyToUlLi[i].onclick = function () {
        for (var j = 0; j < copyToUlLi.length; j++) {
            copyToUlLi[j].className = "";
        }
        this.className = "move_bac_click ";
    }
}
//按下键盘shift多选
var rem=new Array();
var shiftCenterFolder = $(".center_folder_ul > li");
function shift_select(){
    shiftCenterFolder.click(function (e){
        rem.push(shiftCenterFolder.index($(this)));
        if(e.shiftKey){
            $(".seek_download_span").text("批量下载");
            var iMin =  Math.min(rem[rem.length-2],rem[rem.length-1])
            var iMax =  Math.max(rem[rem.length-2],rem[rem.length-1])
            for(i=iMin;i<=iMax;i++){
                shiftCenterFolder[i].className = "center_folder_ul_li";
                arr.eq(i).prop("checked",true);
            }
            $(".folder_a_02").hide();
            $(".folder_center_checkbox").prop("checked",false);
            if(iMax - iMin == iMax && iMax == shiftCenterFolder.length-1) {
                $(".folder_center_checkbox").prop("checked",true);
                $(".folder_checkbox").prop("checked",true)
            }
        }
    });
}
$(function(){
    shift_select();
});
//点击空白处隐藏
var _flag = false;
$(".center_folder_ul li").mouseover(function () {
    _flag = true;
});
$(".center_folder_ul li").mouseleave(function () {
    _flag = false;
});
$(".firm_name_ul").mouseleave(function () {
    _flag = false;
});
$(".firm_name_ul").mouseover(function () {
    _flag = true;
});
$(".folder_ul").mouseleave(function () {
    _flag = false;
});
$(".folder_ul").mouseover(function () {
    _flag = true;
});
$(".seek_ul").mouseleave(function () {
    _flag = false;
});
$(".seek_ul").mouseover(function () {
    _flag = true;
});
$(".confirm_delete").mouseleave(function () {
    _flag = false;
});
$(".confirm_delete").mouseover(function () {
    _flag = true;
});
$(".move_to").mouseleave(function () {
    _flag = false;
});
$(".move_to").mouseover(function () {
    _flag = true;
});
$(".copy_to").mouseleave(function () {
    _flag = false;
});
$(".copy_to").mouseover(function () {
    _flag = true;
});
$(".folder_center_checkbox").mouseleave(function () {
    _flag = false;
});
$(".folder_center_checkbox").mouseover(function () {
    _flag = true;
});
$(".center_top_right").mouseleave(function () {
    _flag = false;
});
$(".center_top_right").mouseover(function () {
    _flag = true;
});
$(".bounce_top").mouseleave(function () {
    _flag = false;
});
$(".bounce_top").mouseover(function () {
    _flag = true;
});
$(document).click(function () {
    if (!_flag){
        for(var i = 0; i < shiftCenterFolder.length; i++) {
            shiftCenterFolder[i].className = "";
        }
        $(".folder_center_checkbox").prop("checked",false);
        $(".folder_a_02 ").hide();
        $(".seek_ul").hide();
        $(".firm_name_01 :checkbox,.folder_checkbox").prop("checked", false);
        $(".center_input").hide();
        $(".center_folder_ul_span").show();
        $(".folder_strike").hide();
        $(".folder_strike_02").slideUp();
    }
});
//新版本
$(".new_release_cancel").click(function () {
    $(".new_release").hide();
    //刷新页面
    location.reload();
})
/*
var uploader = new plupload.Uploader({ //实例化一个plupload上传对象
    // browse_button : 'browse',
    drop_element : 'drag-area',
    url : 'head.html',
    flash_swf_url : 'js/Moxie.swf',
    silverlight_xap_url : 'js/Moxie.xap',
});
uploader.init(); //初始化
//绑定文件添加进队列事件
uploader.bind('FilesAdded',function(uploader,files){
    for(var i = 0, len = files.length; i<len; i++){
        var file_name = files[i].name; //文件名
        //构造html来更新UI
        var html = '<li id="file-' + files[i].id +'"><p class="file-name">' + file_name + '</p><p class="progress"></p></li>';
        $(html).appendTo('#file-list');
    }
});*/
//关闭错误醒
$(".alert_warning_a").click(function() {
    $(".alert-warning").slideUp();
});
//鼠标移入缩略图显示详细信息
var centerFolderUlSpan = $(".center_folder_ul_span");
for(var i = 0; i < centerFolderUlSpan.length; i++) {
    centerFolderUlSpan[i].onmouseenter = function () {
        centerFolderUlSpan.attr("title",$(this).text());
    }
}
//列表缩略图相关联
$(".firm_name_checkbox").click(function() {
    if ($(".folder_checkbox").prop('checked') == true) {
        $(".folder_center_checkbox").prop("checked",true);
    }else {
        $(".folder_center_checkbox").prop("checked",false);
    }
    $('.firm_name_checkbox').each(function(i,val) {
        if ($(this).prop('checked') == true) {
            centerFolderUlLi[i].className = "center_folder_ul_li"
        }else {
            centerFolderUlLi[i].className = ""
        }
    });
});
$(".folder_checkbox").click(function() {
    centerFolderUlLi.each(function(i) {
        if ($(".folder_checkbox").prop('checked') == true) {
            centerFolderUlLi[i].className = "center_folder_ul_li";
            $(".folder_center_checkbox").prop("checked",true);

        }else {
             centerFolderUlLi[i].className = "";
            $(".folder_center_checkbox").prop("checked",false);
        }
    });
});
//列表后缀ioc
var liImg = $(".firm_name_01 > img");
var liImgArray = [];
var liAArray = [];
//['png','jpg','ai','asp','avi','bmp','css','doc','dwg','email','excel','flash','html','id','java','json','mp3','mp4','other','pdf','ppt','ps','rar','swf','text','url','wav','wma','wmv','wps','zip']
var path = ["/static/images/icon/icon_small/png01.png","/static/images/icon/icon_small/jpeg01.png","/static/images/icon/icon_small/gif01.png","/static/images/icon/icon_small/ai01.png","/static/images/icon/icon_small/asp01.png","/static/images/icon/icon_small/avi01.png","/static/images/icon/icon_small/bmp01.png","/static/images/icon/icon_small/css01.png","/static/images/icon/icon_small/doc01.png","/static/images/icon/icon_small/dwg01.png","/static/images/icon/icon_small/email01.png","/static/images/icon/icon_small/excel01.png","/static/images/icon/icon_small/flash01.png","/static/images/icon/icon_small/html01.png","/static/images/icon/icon_small/id01.png","/static/images/icon/icon_small/java01.png","/static/images/icon/icon_small/json01.png","/static/images/icon/icon_small/mp301.png","/static/images/icon/icon_small/mp401.png","/static/images/icon/icon_small/other01.png","/static/images/icon/icon_small/pdf01.png","/static/images/icon/icon_small/ppt01.png","/static/images/icon/icon_small/ps01.png","/static/images/icon/icon_small/rar01.png","/static/images/icon/icon_small/swf01.png","/static/images/icon/icon_small/text01.png","/static/images/icon/icon_small/url01.png","/static/images/icon/icon_small/wav01.png","/static/images/icon/icon_small/wma01.png","/static/images/icon/icon_small/wmv01.png","/static/images/icon/icon_small/wps01.png","/static/images/icon/icon_small/zip01.png"];
for (var i = 0; i < liImg.length; i++) {        
    liImgArray[i] = liImg[i];
}
 var liA = $(".firm_name_01 > a");
for (var i = 0; i < liA.length; i++) {
    liAArray[i] = liA[i];
}
for (var i = 0; i < liAArray.length; i++) { 
    var fileExtension = liAArray[i].firstChild.data.split('.').pop().toLowerCase();
    if(fileExtension == "png") {      
        liImgArray[i].setAttribute('src',path[0]);   
    }else if(fileExtension == "jpg") {    
        liImgArray[i].setAttribute('src',path[1]); 
    }else if(fileExtension == "jpeg") {    
        liImgArray[i].setAttribute('src',path[1]); 
    }else if(fileExtension == "gif") {         
        liImgArray[i].setAttribute('src',path[2]); 
    }else if(fileExtension == "ai") {         
        liImgArray[i].setAttribute('src',path[3]); 
    }else if(fileExtension == "asp") {           
        liImgArray[i].setAttribute('src',path[4]); 
    }else if(fileExtension == "avi") {           
        liImgArray[i].setAttribute('src',path[5]); 
    }else if(fileExtension == "bmp") {           
        liImgArray[i].setAttribute('src',path[6]); 
    }else if(fileExtension == "css") {           
        liImgArray[i].setAttribute('src',path[7]); 
    }else if(fileExtension == "doc") {           
        liImgArray[i].setAttribute('src',path[8]); 
    }else if(fileExtension == "docx") {           
        liImgArray[i].setAttribute('src',path[8]); 
    }else if(fileExtension == "dwg") {           
        liImgArray[i].setAttribute('src',path[9]); 
    }else if(fileExtension == "email") {           
        liImgArray[i].setAttribute('src',path[10]); 
    }else if(fileExtension == "excel") {           
        liImgArray[i].setAttribute('src',path[11]); 
    }else if(fileExtension == "flash") {           
        liImgArray[i].setAttribute('src',path[12]); 
    }else if(fileExtension == "html") {           
        liImgArray[i].setAttribute('src',path[13]); 
    }else if(fileExtension == "id") {           
        liImgArray[i].setAttribute('src',path[14]); 
    }else if(fileExtension == "java") {           
        liImgArray[i].setAttribute('src',path[15]); 
    }else if(fileExtension == "json") {           
        liImgArray[i].setAttribute('src',path[16]); 
    }else if(fileExtension == "mp3") {           
        liImgArray[i].setAttribute('src',path[17]); 
    }else if(fileExtension == "mp4") {           
        liImgArray[i].setAttribute('src',path[18]); 
    }else if(fileExtension == "other") {           
        // liImgArray[i].setAttribute('src',path[19]); 
    }else if(fileExtension == "pdf") {           
        liImgArray[i].setAttribute('src',path[20]); 
    }else if(fileExtension == "ppt") {           
        liImgArray[i].setAttribute('src',path[20]); 
    }else if(fileExtension == "pptx") {           
        liImgArray[i].setAttribute('src',path[21]); 
    }else if(fileExtension == "ps") {           
        liImgArray[i].setAttribute('src',path[22]); 
    }else if(fileExtension == "rar") {           
        liImgArray[i].setAttribute('src',path[23]); 
    }else if(fileExtension == "swf") {           
        liImgArray[i].setAttribute('src',path[24]); 
    }else if(fileExtension == "txt") {           
        liImgArray[i].setAttribute('src',path[25]); 
    }else if(fileExtension == "url") {           
        liImgArray[i].setAttribute('src',path[26]); 
    }else if(fileExtension == "wav") {           
        liImgArray[i].setAttribute('src',path[27]); 
    }else if(fileExtension == "wma") {           
        liImgArray[i].setAttribute('src',path[28]); 
    }else if(fileExtension == "wmv") {           
        liImgArray[i].setAttribute('src',path[29]); 
    }else if(fileExtension == "wps") {           
        liImgArray[i].setAttribute('src',path[30]); 
    }else if(fileExtension == "zip") {           
        liImgArray[i].setAttribute('src',path[31]); 
    }
}
//缩略图后缀ioc
var liImgS = $(".folder_a_01 > img");
var liImgArrayS = [];
var liAArrayS = [];
var pathS = ["/static/images/icon/icon_big/png.png","/static/images/icon/icon_big/jpeg.png","/static/images/icon/icon_big/gif.png","/static/images/icon/icon_big/ai.png","/static/images/icon/icon_big/asp.png","/static/images/icon/icon_big/avi.png","/static/images/icon/icon_big/bmp.png","/static/images/icon/icon_big/css.png","/static/images/icon/icon_big/doc.png","/static/images/icon/icon_big/dwg.png","/static/images/icon/icon_big/email.png","/static/images/icon/icon_big/excel.png","/static/images/icon/icon_big/flash.png","/static/images/icon/icon_big/html.png","/static/images/icon/icon_big/id.png","/static/images/icon/icon_big/java.png","/static/images/icon/icon_big/json.png","/static/images/icon/icon_big/mp3.png","/static/images/icon/icon_big/mp4.png","/static/images/icon/icon_big/other.png","/static/images/icon/icon_big/pdf.png","/static/images/icon/icon_big/ppt.png","/static/images/icon/icon_big/ps.png","/static/images/icon/icon_big/rar.png","/static/images/icon/icon_big/swf.png","/static/images/icon/icon_big/text.png","/static/images/icon/icon_big/url.png","/static/images/icon/icon_big/wav.png","/static/images/icon/icon_big/wma.png","/static/images/icon/icon_big/wmv.png","/static/images/icon/icon_big/wps.png","/static/images/icon/icon_big/zip.png"];
for (var i = 0; i < liImgS.length; i++) {     
    liImgArrayS[i] = liImgS[i];
}
 var liAS = $(".folder_a_01 > a");
for (var i = 0; i < liAS.length; i++) {         
    liAArrayS[i] = liAS[i];
}
for (var i = 0; i < liAArrayS.length; i++) {   
    var fileExtensionS = liAArrayS[i].firstChild.data.split('.').pop().toLowerCase();
    //文件
    $(".file_diff_omit img").css({"width":"40px"});
    $(".file_diff_omit img").css({"height":"52px"});
    $(".file_diff_list img").css({"width":"20px"});
    //文件夹
    $(".folder_diff_omit img").css({"width":"52px"});
    $(".folder_diff_omit img").css({"height":"42px"});
    //文件后缀图标
    if(fileExtensionS == "png") {      
        liImgArrayS[i].setAttribute('src',pathS[0]);   
    }else if(fileExtensionS == "jpg") {    
        liImgArrayS[i].setAttribute('src',pathS[1]); 
    }else if(fileExtensionS == "jpeg") {    
        liImgArrayS[i].setAttribute('src',pathS[1]); 
    }else if(fileExtensionS == "gif") {         
        liImgArrayS[i].setAttribute('src',pathS[2]); 
    }else if(fileExtensionS == "ai") {         
        liImgArrayS[i].setAttribute('src',pathS[3]); 
    }else if(fileExtensionS == "asp") {           
        liImgArrayS[i].setAttribute('src',pathS[4]); 
    }else if(fileExtensionS == "avi") {           
        liImgArrayS[i].setAttribute('src',pathS[5]); 
    }else if(fileExtensionS == "bmp") {           
        liImgArrayS[i].setAttribute('src',pathS[6]); 
    }else if(fileExtensionS == "css") {           
        liImgArrayS[i].setAttribute('src',pathS[7]); 
    }else if(fileExtensionS == "doc") {           
        liImgArrayS[i].setAttribute('src',pathS[8]); 
    }else if(fileExtensionS == "docx") {           
        liImgArrayS[i].setAttribute('src',pathS[8]); 
    }else if(fileExtensionS == "dwg") {           
        liImgArrayS[i].setAttribute('src',pathS[9]); 
    }else if(fileExtensionS == "email") {           
        liImgArrayS[i].setAttribute('src',pathS[10]); 
    }else if(fileExtensionS == "excel") {           
        liImgArrayS[i].setAttribute('src',pathS[11]); 
    }else if(fileExtensionS == "flash") {           
        liImgArrayS[i].setAttribute('src',pathS[12]); 
    }else if(fileExtensionS == "html") {           
        liImgArrayS[i].setAttribute('src',pathS[13]); 
    }else if(fileExtensionS == "id") {           
        liImgArrayS[i].setAttribute('src',pathS[14]); 
    }else if(fileExtensionS == "java") {           
        liImgArrayS[i].setAttribute('src',pathS[15]); 
    }else if(fileExtensionS == "json") {           
        liImgArrayS[i].setAttribute('src',pathS[16]); 
    }else if(fileExtensionS == "mp3") {           
        liImgArrayS[i].setAttribute('src',pathS[17]); 
    }else if(fileExtensionS == "mp4") {           
        liImgArrayS[i].setAttribute('src',pathS[18]); 
    }else if(fileExtensionS == "other") {           
        // liImgArrayS[i].setAttribute('src',pathS[19]); 
    }else if(fileExtensionS == "pdf") {           
        liImgArrayS[i].setAttribute('src',pathS[20]); 
    }else if(fileExtensionS == "ppt") {           
        liImgArrayS[i].setAttribute('src',pathS[20]); 
    }else if(fileExtensionS == "pptx") {           
        liImgArrayS[i].setAttribute('src',pathS[21]); 
    }else if(fileExtensionS == "ps") {           
        liImgArrayS[i].setAttribute('src',pathS[22]); 
    }else if(fileExtensionS == "rar") {           
        liImgArrayS[i].setAttribute('src',pathS[23]); 
    }else if(fileExtensionS == "swf") {           
        liImgArrayS[i].setAttribute('src',pathS[24]); 
    }else if(fileExtensionS == "txt") {           
        liImgArrayS[i].setAttribute('src',pathS[25]); 
    }else if(fileExtensionS == "url") {           
        liImgArrayS[i].setAttribute('src',pathS[26]); 
    }else if(fileExtensionS == "wav") {           
        liImgArrayS[i].setAttribute('src',pathS[27]); 
    }else if(fileExtensionS == "wma") {           
        liImgArrayS[i].setAttribute('src',pathS[28]); 
    }else if(fileExtensionS == "wmv") {           
        liImgArrayS[i].setAttribute('src',pathS[29]); 
    }else if(fileExtensionS == "wps") {           
        liImgArrayS[i].setAttribute('src',pathS[30]); 
    }else if(fileExtensionS == "zip") {           
        liImgArrayS[i].setAttribute('src',pathS[31]); 
    }
}
//文件夹图标
    $(".folder_diff_omit img").attr("src","/static/images/ic_folder01.png");
    $(".folder_diff_list img").attr("src","/static/images/ic_folder.png");